package cn.growthgate.fgo.util;

import java.util.Collection;

public class ArrayUtils extends org.apache.commons.lang3.ArrayUtils {

	/**
	 * 将对象转化为object数组
	 * @param obj
	 * @return
	 */
	public static Object[] toObject(Object obj) {
		if (obj == null) {
			return null;
		}
		if (obj.getClass().isArray()) {
			if (obj instanceof boolean[]) {
				return toObject((boolean[]) obj);
			} else if (obj instanceof byte[]) {
				return toObject((byte[]) obj);
			} else if (obj instanceof char[]) {
				return toObject((char[]) obj);
			} else if (obj instanceof short[]) {
				return toObject((short[]) obj);
			} else if (obj instanceof int[]) {
				return toObject((int[]) obj);
			} else if (obj instanceof long[]) {
				return toObject((long[]) obj);
			} else if (obj instanceof float[]) {
				return toObject((float[]) obj);
			} else if (obj instanceof double[]) {
				return toObject((double[]) obj);
			} else {
				return (Object[]) obj;
			}
		} else if (obj instanceof Collection<?>) {
			return ((Collection<?>) obj).toArray();
		} else {
			return new Object[]{obj};
		}
	}
	
}
